/*
 * @Author: 姚贤通 10254465+yao-xiantong@user.noreply.gitee.com
 * @Date: 2022-11-16 18:55:37
 * @LastEditors: 姚贤通 10254465+yao-xiantong@user.noreply.gitee.com
 * @LastEditTime: 2022-11-20 14:58:18
 * @FilePath: \vue\src\api\course.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
//引入封配置好的axios

import http from '../utils/request.js'

//对同一个表的操作写在同一api文件内   
//下面以user表的api为例
//向外暴露这个整个user表的api
export default {

    //根据学生ID查询所有学生所选课程信息
    queryAllCourseByStudentId(params) {
        return http.get('/course/queryAllCourseByStudentId?userID=' + params);

    },

    //根据教师ID查询所有开课程信息
    queryAllCourseByTeacherId(params) {
        return http.get('/course/queryAllCourseByTeacherId?userID=' + params);

    },


    // 根据课程暗号查询数据库是否有该课程，（1 为有，0 为无）
    isHaveCourseByCode(params){
        return http.get('/course/isHaveCourseByCode?classCode=' + params);
    },

    
     // 根据学生id和课程暗号添加课程
     addClassStudentByCourseCode(params){
        return http.post('course/addClassStudentByCourseCode',params);
    },

    // 根据学生id和课程id删除课程
    deleteClassStudentByCourseId(params){
        return http.post('course/deleteClassStudentByCourseId',params);
    },

    
    // 获取课程，班级列表
    queryCourseClassList(teacherId){
        teacherId = "1";
        return http.post('course/queryCourseClassList',{
            teacherId:teacherId,
        },{
           headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        });
    },

    createCourse(from){

        return http.post('course/createCourse',
            from
        ,{ 
            headers:{ 'Content-Type':'application/x-www-form-urlencoded;charset=UTF-8' }
         });

    },
    
    createClass(classfrom){

        
        return http.post('class/createClass',
            classfrom,
            {
                     headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
                 }
        );

    },
    delCourse(i){

        return http.post('course/delCourse',{
            courseId:i,
        },{
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        });

    },
    delClass(id){

        return http.post('class/delClass',{
            classId:id,
        },{
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        });
    },
    updateCourse(parm){

        
        return http.post('course/updateCourse',
            parm,
        {
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        });
    },

    updateClass(calssform){

        

        return http.post('class/updateClass',
        calssform,
        {
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        });
    },

    queryClassByCourseIdAndstudentId(studentId){

        return http.post('class/queryClassByCourseId',{
            studentId:studentId,
        
        },{
            headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        });

    }


}